{include file='public/header' /}
<div class="layuimini-container">
    <form id="modelUserForm" lay-filter="modelUserForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <input name="description" type="hidden" value="机构简介" />
        <input name="thumb" type="hidden" value="http://bgt-param.oss-cn-hangzhou.aliyuncs.com/upload/20200715/262ff0a28dabe9bfd44c4356d1014de6450d5444.png" />

        <div class="layui-form-item">
            <label for="" class="layui-form-label">分类</label>
            <div class="layui-input-block">
                <select name="category_id" search lay-verify="required">
                    <option value="0">请选择</option>
                    {volist name='data.cate' id='vo'}
                    <option value="{$vo.id}">{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">标签</label>
            <div class="layui-input-block" >
                {volist name='data.tag' id='vo'}
                <input type="checkbox" name="tags[]" value="{$vo.id ?? ''}" title="{$vo.name ?? ''}">
                {/volist}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">商家星级</label>
            <div class="layui-input-block">
                <input name="star" placeholder="请输入商家星级，填写0~5" type="number" class="layui-input" maxlength="1"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">商家名称</label>
            <div class="layui-input-block">
                <input name="name" value="" placeholder="请输入商家名称,最多50个字" type="text" class="layui-input" maxlength="50"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">商家地址</label>
            <div class="layui-input-block">
                <input name="address" placeholder="请输入商家地址，最多100个字" type="text" class="layui-input" maxlength="100"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">商家电话</label>
            <div class="layui-input-block">
                <input name="phone" placeholder="请输入商家电话，最多20个数字" type="text" class="layui-input" maxlength="20"
                       lay-verType="tips" lay-verify="required" required/>
                <p> <span style="color: grey ">座机格式：0571-8888 8888 手机号格式：138******88</span></p>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">排序</label>
            <div class="layui-input-block">
                <input name="sort" placeholder="请输入排序" type="text" class="layui-input" maxlength="20"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item text-right">

            <button class="layui-btn layui-btn-primary" type="button" onclick="close_window()" ew-event="closePageDialog">取消</button>
            <button class="layui-btn" lay-filter="modelSubmitUser" lay-submit>保存</button>
        </div>
    </form>
</div>
{include file='public/footer' /}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;


        var url = '{:__url("mall.store/add")}';

        // 表单提交事件
        form.on('submit(modelSubmitUser)', function (data) {
            layer.load(2);
            console.log(data);
            $.post(url, data.field, function (res) {

                layer.closeAll('loading');
                if (res.code == 1) {
                    layer.msg(res.msg, {icon: 1,time: 1000},function(index){
                        window.parent.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'json');
            return false;
        });
    });
    function close_window(){
        window.parent.location.reload();
    }
</script>